<?php
/**
 * 质押及质押算力
 */
namespace app\api\model;
use app\common\model\MiningPledge as MiningPledgeModel;

class MiningPledge extends MiningPledgeModel
{
    /**
     * 添加记录
     * @param $mid 用户ID
     * @param $mining_id 矿机ID
     * @param $mining_order_id  矿机订单ID
     * @param $num  存入数量  / 奖励方算力
     * @param $mining_oneself   1:矿机本人 2:奖励方
     * @return int|string
     */
    public static function add($mid,$mining_id,$mining_order_id,$num,$mining_oneself){
        $data = [
            'mid'   =>  $mid,
            'mining_id'   =>  $mining_id,
            'mining_order_id'   =>  $mining_order_id,
            'type'   =>  $num > 0 ? 1: 2,
            'num'   =>  $num,
            'mining_oneself'   =>  $mining_oneself,
            'add_time'   =>  date('Y-m-d H:i:s',time()),
        ];
        return  self::insertGetId($data);
    }
}